<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script src="./lib/vue.js"></script>
</body>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./lib/vue.js"></script>
  <style>
    .red {
      color: red;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- 对象方式 -->
    <div :class="{red:red}">我是一个标题</div>
    <!-- 数组方式 -->
    <div :class="[arrRed]">我是一个标题</div>
    <button @click="closeRed">关闭加红</button>
  </div>

  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        red: true,
        arrRed:'red'
      },
      methods: {
        closeRed() {
          this.red = !this.red;
        }
      }
    })
  </script>
</body>

</html>